package com.xz.knowledgeDuplication.pattern.flyweight;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 召
 * @date 2022-03-14 21:43:38
 */
public class BoxFactory {

    private static BoxFactory boxFactory = new BoxFactory();

    private Map<String, AbstractBox> map = new HashMap<String, AbstractBox>();

    public static BoxFactory getInstance() {
        return boxFactory;
    }

    private BoxFactory () {
        map.put("I", new IBox());
        map.put("L", new LBox());
        map.put("O", new OBox());
    }

    public AbstractBox getBox(String key) {
        return map.get(key);
    }
}
